package com.gyh.system.scheduler.entity;

import org.apache.commons.lang3.StringUtils;

import com.gyh.system.common.persistence.BaseEntity;

/**
 * 定时任务实体类
 * @author Administrator
 */
public class ScheduleJob extends BaseEntity<ScheduleJob>{

	private static final long serialVersionUID = 1L;
	
	//调度参数
	public static final String JOB_PARAM_KEY = "JOB_PARAM_KEY";

	private String jobName;				// jon 名称
	private String beanName;			// spring bean名称
	private String methodName;			// 方法名
	private String params;				// 参数
	private String cronExpression;		// cron 表达式
	private Integer status;				// job 状态
	
	public ScheduleJob() {
		super();
	}
	
	public ScheduleJob(Long id) {
		super(id);
	}

	public String getJobName() {
		return jobName;
	}
	public void setJobName(String jobName) {
		this.jobName = jobName;
	}
	public String getBeanName() {
		return beanName;
	}
	public void setBeanName(String beanName) {
		this.beanName = beanName;
	}
	public String getMethodName() {
		return methodName;
	}
	public void setMethodName(String methodName) {
		this.methodName = methodName;
	}
	public String getParams() {
		return params;
	}
	public void setParams(String params) {
		this.params = params;
	}
	public String getCronExpression() {
		return cronExpression;
	}
	public void setCronExpression(String cronExpression) {
		this.cronExpression = cronExpression;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}

	@Override
	public String toString() {
		return "ScheduleJob [jobName=" + jobName + ", beanName=" + beanName + ", methodName=" + methodName + ", params="
				+ params + ", cronExpression=" + cronExpression + ", status=" + status + "]";
	}

	public String toJson() {
		return "{\"id\":" + this.toNull(super.getId()) + ",\"jobName\":" + this.toNull(jobName) + ", \"beanName\":" + this.toNull(beanName) + ", \"methodName\":" + this.toNull(methodName) + ","
				+ " \"params\":"+ this.toNull(params) + ", \"cronExpression\":" + this.toNull(cronExpression) + ", \"status\":" + this.toNull(status) + "}";
	}
	
	private String toNull(Object obj) {
		if ( obj != null && StringUtils.isNoneBlank(obj.toString())) {
			return "\""+obj.toString()+"\"";
		} else {
			return null;
		}
	}
	
	
	
}
